<template>
    <el-dialog :visible="visible" title="编辑纳税人识别号" width="600px" @close="onClose" @open="onOpen">
        <el-form class="form" :model="config" label-width="120px" label-position="right" hide-required-asterisk>
            <el-form-item>
                <span slot="label" style="color: #ff0000">纳税人识别号</span>
                <el-input v-model="identificationNumbe"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button class="bottom_all_two" @click="onClose">取 消</el-button>
            <el-button class="bottom_all" type="primary" @click="onConfirm">确 定</el-button>
        </span>
    </el-dialog>
</template>

<script>
    import { changefinacialCode } from "@/api/internetSales/performanceRecord.js"

    export default {
        data() {
            return {
                identificationNumbe: '',
            };
        },
        computed: {},
        props: {
            config: {
                type: Object,
                default: () => ({}),
            },
            // 控制dialog显示
            visible: {
                type: Boolean,
            },
        },
        watch: {},
        // 方法集合
        methods: {
            async onConfirm() {
                const identificationNumbe = this.identificationNumbe.replace(/\s+/g,""); // 去空格
                const params = {
                    identificationNumbe,
                    id: this.config.id
                }
                const res = await changefinacialCode(params);
                res && res.code === 1001?this.$message.success("修改成功"):this.$message.error("修改失败")
                this.$emit("updated", false);
                this.$emit('update:visible', false);
            },
            onClose() {
                this.$emit('update:visible', false);
            },
            onOpen() {
                this.financialCode = this.config.financialCode;
            }
        },
    };
</script>
<style lang="scss" scoped></style>
